const { searchUser,searchuserByid } = require('../dao/dbserver/user')
const { isFriend,getFriend,getnewFriend } = require('../dao/dbserver/friend')
const { searchGroup,exist,searchGroupByid } = require('../dao/dbserver/group')
const { isGroup,ismygroup,getGroupUser } = require('../dao/dbserver/member')
const other = require('../dao/dbserver/other')
const { getmessage, notreadcount } = require('../dao/dbserver/message')
const { getgmessage, getnews } = require('../dao/dbserver/gmessage')

exports.SearchUser = (req, res, next) => {
    const { key,id } = req.query
    searchUser(key, id,res)
}

exports.IsFriend = (req, res, next) => {
    const { uid, fid } = req.query
    isFriend(uid, fid, res)
}

exports.SearchGroup = (req, res, next) => {
    const { key,id } = req.query
    searchGroup(key,id, res)
}
exports.IsGroup = (req, res, next) => {
    const { uid, gid } = req.query
    isGroup(uid, gid, res)
}

exports.GetFriend = (req,res,next)=>{
    const {id}= req.query
    getFriend(id,res)
}

exports.GroupExist = (req,res,next)=>{
    const {name} = req.query
    exist(name,res)
}

exports.searchnewFriend = (req,res,next)=>{
    var {id} =req.query
    getnewFriend(id,res)

}

exports.isMygroup = (req,res,next)=>{
    const {id} =  req.query
    ismygroup(id,res)
}

exports.getuserother = (req,res,next)=>{
    var {uid,fid} =  req.query
    other.user(uid,fid,res)
}   

exports.getgroupother = (req,res,next)=>{
    var {gid} =  req.query
    other.group(gid,res)
}   

exports.getuserbyid = (req,res,next)=>{
    var {id} = req.query
    searchuserByid(id,res)
}

exports.getgroupbyid = (req,res,next)=>{
    var {id} =  req.query
    searchGroupByid(id,res)
}

exports.getmember =  (req,res,next)=>{
    var {id} = req.query
    getGroupUser(id,res)

}   

exports.getMessage = (req,res,next)=>{
    var {uid,fid,page,pagesize} = req.query
    getmessage(uid,fid,pagesize,page,res)
}


exports.getgmsg = (req,res,next)=>{
    var {gid,page,pagesize} = req.query
    getgmessage(gid,pagesize,page,res)
}

exports.notRead = (req,res,next)=>{
    const {uid,fid} = req.query
    notreadcount(uid,fid,res)
}

exports.getNews = (req,res,next)=>{
const {gid} = req.query
getnews(gid,res)
}